package com.example.demo.controller;

import com.alibaba.fastjson.JSONArray;
import com.example.demo.dto.timesheet.TimeSheetDto;
import com.example.demo.entity.TimeSheet;
import com.example.demo.service.ITimeSheetService;
import com.example.demo.utils.list.ListUtils;
import com.example.demo.utils.result.Result;
import com.example.demo.utils.result.ResultUtils;
import com.example.demo.vo.timesheet.TimeSheetVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.Time;
import java.util.ArrayList;
import java.util.List;

/**
 * 时间表
 */
@RestController
@RequestMapping("timesheet")
public class TimeSheetController extends BaseController {
    @Autowired
    ITimeSheetService timeSheetService;

    @PostMapping("selectListByVersion")
    public Result selectListByVersion(@RequestBody TimeSheetDto timeSheetDto) {
        String version = timeSheetDto.getVersion();
        List<TimeSheet> timeSheetList = timeSheetService.selectListByVersion(version).orElse(new ArrayList<>());
        List<TimeSheetVo> timeSheetVoList = ListUtils.copyListProperties(timeSheetList, TimeSheetVo.class);
        return ResultUtils.success(timeSheetVoList);
    }
}
